<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script>
    function success(position) {
        var coords = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
        var lat = position.coords.latitude;
        var longitude = position.coords.longitude;
        document.getElementById('lat').value = lat;
        document.getElementById('long').value = longitude;
    }
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(success);
    } else {
        error('Geo Location is not supported');
    }
</script>
<form method="post" id="form_visita" action="controller/acoes_visita.php" enctype="multipart/form-data" >
    <input type="hidden" name="hdCodCliente" id="hdCodCliente" />
    <table>
        <tr>
            <td>
                <?php
                $listaUF = Municipios::listaUfMunicipio(" GROUP BY uf ORDER BY uf ");
                ?>
                <select name="cmbUf" id="cmbUf" onchange="ListaMunicipios(this)" class="campo">
                    <option value=""></option>
                    <?php
                    foreach ($listaUF as $key) {
                        ?>
                        <option value="<?php echo $key->getUf(); ?>"><?php echo $key->getUf(); ?></option>
                        <?php
                    }
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td><hr size="1" color="#000000" /></td>
        </tr>
        <tr>
            <td id="tdRetorno"><select name="cbMunicipios" class="campo" id="cbMunicipios">
                    <option value=""></option>
                </select></td>
        </tr>
        <tr>
            <td><hr size="1" color="#000000" /></td>
        </tr>
        <tr>
            <td id="tdRetornoPostos">
                <select class="campo" name="cmbListaPostos" id="cmbListaPostos">
                    <option value=""></option>
                </select></td>
        </tr>
        <tr>
            <td><hr size="1" color="#000000" /></td>
        </tr>
        <tr>
            <td><input type="text" name="txtDataVisita" id="txtDataVisita" class="campo" size="10" placeholder="Data" /></td>
        </tr>
        <tr>
            <td><hr size="1" color="#000000" /></td>
        </tr>
        <tr>
                <td class="titulo" colspan="2" >Foto</td>
            </tr>
            <tr><td colspan="2">
            <div style="width: 400px;" id="Foto">
                <input type="hidden" id="cont_file" value="0"/>
                <input type="file" style="color:white;" name="foto[]" id="foto0" /><input type="button" id="addFoto" name="addFoto" value="+"/>
            </div>    
                </td>
        </tr>
        <tr>
            <td><hr size="1" color="#000000" /></td>
        </tr>
            <tr>
                <td class="titulo">Arquivo:</td>
            </tr>
            <tr><td colspan="2">
            <div style="width: 400px;" id="uploadFile">
                <input type="hidden" id="contFile" value="0"/>
                <input type="file" style="color:white;" name="file[]" id="foto0" /><input type="button" id="addFile" name="addFile" value="+"/>
            </div>    
                </td></tr>
        <tr>
            <td><hr size="1" color="#000000" /></td>
        </tr>
        <tr>
            <td>
                <font style="color:white">Descri&ccedil;&atilde;o</font><br />
                <textarea name="txtDescricao" id="txtDescricao" placeholder="Descri&ccedil;&atilde;o da visita" class="campo"></textarea>
            </td>
        </tr>
        <tr>
            <td><hr size="1" color="#000000" /></td>
        </tr>
        <tr>
            <td>
                <input type="hidden" name="lat" id="lat"/>
                <input type="hidden" name="long" id="long"/>            
                <input type="button" disabled="disabled" class="botao2" id="checkin" name="checkin" value="CHECK-IN" />
            </td>
        </tr>
        <tr><td><div id="div_checkin" ></div></td></tr>
        <tr>
            <td><hr size="1" color="#000000" /></td>
        </tr>
        <tr>
            <td>
                <input type="submit" name="btSalvar" id="btSalvar" class="botao2" value="Salvar" onclick="return ValidaFormulario('cmbUf|cbMunicipios|cmbListaPostos|txtDataVisita','Preencha os campos requeridos');" />
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
        </tr>

    </table>
</form>

<script type="text/javascript">
    function removeFotoUp(a){
        var	a = a;
        //$('br:last').remove();
        $("#delFoto"+a).remove();
        $("#foto"+a).remove();
    }
    function removeUpFile(a){
        var	a = a;
        $("#del"+a).remove();
        $("#file"+a).remove();
    }


</script>